#include "../../server.hpp"


int main(){
    Socket sock;
    bool ret = sock.CreateServer(8500, "127.0.0.1", false);
    if(ret < 0){
        return -1;
    }
    while(1){
        int newfd = sock.Accept();
        if(newfd < 0) continue;
        Socket cli_sock(newfd);
        
        char buff[1024] = {0};
        int rcv = cli_sock.Recv(buff, sizeof(buff));
        DEBUG_LOG("svrrcv:%d", rcv);
        if(rcv < 0){
            DEBUG_LOG("rcv<0");
            cli_sock.Close();
            continue;
        }
        buff[rcv] = '\0';
        printf("svrrcv buff%s", buff);
        cli_sock.Send(buff, rcv);
        DEBUG_LOG("svrsend");

        cli_sock.Close();
    }
    sock.Close();
    return 0;
}